package com.leyou.trade.dto;

import com.leyou.commons.dto.BaseDTO;
import com.leyou.commons.entity.BaseEntity;
import com.leyou.item.dto.SpuDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class DetailsDTO extends BaseDTO {
    /**
     * 商品id
     */
    private Long skuId;
    /**
     * 商品单价
     */
    private Long price;
    /**
     * 商品购买数量
     */
    private Integer num;
    /**
     * 图片
     */
    private String image;
    /**
     * 商品标题
     */
    private String title;
    /**
     * 商品规格数据
     */
    private String spec;
    public DetailsDTO(BaseEntity entity) {
        super(entity);
    }
    public static <T extends BaseEntity> List<DetailsDTO > convertEntityList(Collection<T> list){
        if(list == null){
            return Collections.emptyList();
        }
        return list.stream().map(DetailsDTO::new).collect(Collectors.toList());
    }
}
